/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//Clase BotonX


package net.javahispano.nettools.cliente.Grafico;



import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.plaf.basic.BasicButtonUI;
import net.javahispano.nettols.comunicaciones.Objeto;
import net.javahispano.nettools.cliente.EjecutaComandos;
import net.javahispano.nettools.cliente.Informable;


public class BotonX extends JButton  implements MouseListener,Informable {
 private EjecutaComandos ejecutoDeComandos;
 JTabbedPane panel;
 PanelTab btc;
 int tipo;
 public ArrayList <Consola> lista=new ArrayList <Consola>();

    public BotonX(JTabbedPane pane,PanelTab btc,int op, ArrayList <Consola> lc,EjecutaComandos ejecuto)  {
     ejecutoDeComandos=ejecuto;
        lista=lc;
      panel=pane;
     this.btc=btc;
     tipo=op;
        int size = 17;
        setPreferredSize(new Dimension(size, size));
        setToolTipText("Cerrar Pestaña");
        setUI(new BasicButtonUI());
        setContentAreaFilled(false);
        setFocusable(false);
        setBorder(BorderFactory.createEtchedBorder());
        setBorderPainted(false);
        addMouseListener(this);
        setRolloverEnabled(true);
        addActionListener(new ActionListener(){


   @Override
   public void actionPerformed(ActionEvent e) {
    int i = panel.indexOfTabComponent(BotonX.this.btc);
          if (i != -1) {
              panel.remove(i);
              System.out.println("Eliminamos la pestaña  y la Array correspondiente REMOVEEEE");
              lista.remove(i);
             getEjecutoDeComandos().StatusDescConsola(i);
          }
   }
        });
    }

    @Override
    public void updateUI() {
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g.create();
        if(tipo==0){
         if (getModel().isPressed()) {
          g2.translate(1, 1);
         }
         g2.setStroke(new BasicStroke(3));
         g2.setColor(Color.BLACK);
         if (getModel().isRollover()) {
          g2.setColor(Color.RED);
         }
         g2.drawLine(5, 5, 12, 12);
         g2.drawLine(12, 6, 6, 12);
         g2.dispose();
        }else{
         ImageIcon img=new ImageIcon(this.getClass().getResource("../lib/cerrar.png"));
       //  g2.drawImage(img.getImage(), 1, ,14,14, this);
         g2.dispose();
        }
    }


 @Override
 public void mouseClicked(MouseEvent e) {
  // TODO Auto-generated method stub

 }


 @Override
 public void mouseEntered(MouseEvent e) {
  Component component = e.getComponent();
        if (component instanceof AbstractButton) {
            AbstractButton button = (AbstractButton) component;
            button.setBorderPainted(true);
        }
 }


 @Override
 public void mouseExited(MouseEvent e) {
  Component component = e.getComponent();
        if (component instanceof AbstractButton) {
            AbstractButton button = (AbstractButton) component;
            button.setBorderPainted(false);
        }
 }


 @Override
 public void mousePressed(MouseEvent e) {
  // TODO Auto-generated method stub

 }


 @Override
 public void mouseReleased(MouseEvent e) {
  // TODO Auto-generated method stub

 }

    public void mensageListarProcesos(String ListaDirectorios) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageActualizarListarProcesos(String ListaDirectorios) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageVideo(String NombreCaptura) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageServicios(String ServiciosActivos) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageInformacionEquipo(String informacionEquipo) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void clearShell2() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageReconstruirArbol(String SubdirectoriosArbol) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageInformacionArbol(String datosArbol) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageInformacion(String texto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mensageError(String texto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void informaSobreElProgreso(int progreso) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean isConnected() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void StatusConex(String status) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void StatusDesc(String desc) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void StatusDescConsola(int desc) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Objeto recibeMensaje() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * @return the ejecutoDeComandos
     */
    public EjecutaComandos getEjecutoDeComandos() {
        return ejecutoDeComandos;
    }

    /**
     * @param ejecutoDeComandos the ejecutoDeComandos to set
     */
    public void setEjecutoDeComandos(EjecutaComandos ejecutoDeComandos) {
        this.ejecutoDeComandos = ejecutoDeComandos;
    }
     public void mensageInformacionConsolaVideo(String texto) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}